/*
 * @Author: your name
 * @Date: 2021-09-03 10:05:25
 * @LastEditTime: 2021-09-09 16:50:42
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \ej-webui\src\router\index.js
 */
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [{
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: {
        title: '首页',
        icon: 'dashboard'
      }
    }]
  },
  {
    path: '/column',
    component: Layout,
    children: [{
      path: 'index',
      name: 'Column',
      component: () => import('@/pages/column/index'),
      meta: {
        title: '栏目管理',
        icon: 'column'
      }
    }]
  },
  {
    path: '/production',
    component: Layout,
    children: [{
      path: 'index',
      name: 'Production',
      component: () => import('@/pages/production/index'),
      meta: {
        title: '产品管理',
        icon: 'production'
      }
    }]
  },
  {
    path: '/bill',
    component: Layout,
    meta: {
      title: '账单管理',
      icon: 'bill'
    },
    children: [{
        path: 'customers/index',
        name: 'Customers',
        component: () => import('@/pages/bill/customers/index'),
        meta: {
          title: '顾客账单',
          icon: 'customer'
        }
      },
      {
        path: 'employees/index',
        name: 'Employees',
        component: () => import('@/pages/bill/employees/index'),
        meta: {
          title: '员工账单',
          icon: 'employees'
        }
      },
      {
        path: 'system/index',
        name: 'System',
        component: () => import('@/pages/bill/system/index'),
        meta: {
          title: '系统账单',
          icon: 'system'
        }
      }
    ]
  },
  {
    path: '/auditHall',
    component: Layout,
    meta: {
      title: '审核大厅',
      icon: 'auditHall'
    },
    children: [{
        path: 'accountApply/index',
        name: 'AccountApply',
        component: () => import('@/pages/auditHall/accountApply/index'),
        meta: {
          title: '账户变更',
          icon: 'accountApply'
        }
      },
      {
        path: 'certification/index',
        name: 'Certification',
        component: () => import('@/pages/auditHall/certification/index'),
        meta: {
          title: '实名认证',
          icon: 'certification'
        }
      },
      {
        path: 'infoComment/index',
        name: 'InfoComment',
        component: () => import('@/pages/auditHall/infoComment/index'),
        meta: {
          title: '资讯评论',
          icon: 'infoComment'
        }
      },
      {
        path: 'orderComment/index',
        name: 'OrderComment',
        component: () => import('@/pages/auditHall/orderComment/index'),
        meta: {
          title: '订单评论',
          icon: 'orderComment'
        }
      },
    ]
  },
  {
    path: '/order',
    component: Layout,
    children: [{
      path: 'index',
      name: 'Order',
      component: () => import('@/pages/order/index'),
      meta: {
        title: '订单管理',
        icon: 'order'
      }
    }]
  },
  {
    path: '/customer',
    component: Layout,
    children: [{
      path: 'index',
      name: 'Customer',
      component: () => import('@/pages/customer/index'),
      meta: {
        title: '顾客管理',
        icon: 'customer'
      }
    }]
  },
  {
    path: '/employee',
    component: Layout,
    children: [{
      path: 'index',
      name: 'Employee',
      component: () => import('@/pages/employee/index'),
      meta: {
        title: '员工管理',
        icon: 'employees'
      },
    }],
  },
  {
    path: '/peopleDetails',
    component: Layout,
    children: [{
      path: 'index',
      name: 'PeopleDetails',
      component: () => import('@/pages/employee/details/index'),

    }]
  },
  {
    path: '/orderDetails',
    component: Layout,
    children: [{
      path: 'index',
      name: 'OrderDetails',
      component: () => import('@/pages/order/details/index')
    }]
  },
  {
    path: '/info',
    component: Layout,
    meta: {
      title: '网站咨询',
      icon: 'category'
    },
    children: [{
        path: 'article/index',
        name: 'Article',
        component: () => import('@/pages/info/article/index'),
        meta: {
          title: '咨询信息',
          icon: 'article'
        }
      },
      {
        path: 'category/index',
        name: 'Category',
        component: () => import('@/pages/info/category/index'),
        meta: {
          title: '咨询分类',
          icon: 'category'
        }
      }
    ]
  },
  {
    path: '/role',
    component: Layout,
    meta: {
      title: '角色权限',
      icon: 'role'
    },
    children: [{
        path: 'user/index',
        name: 'User',
        component: () => import('@/pages/role/user/index'),
        meta: {
          title: '用户管理',
          icon: 'user'
        }
      },
      {
        path: 'role/index',
        name: 'Role',
        component: () => import('@/pages/role/role/index'),
        meta: {
          title: '角色管理',
          icon: 'role'
        }
      },
      {
        path: 'privilege/index',
        name: 'Privilege',
        component: () => import('@/pages/role/privilege/index'),
        meta: {
          title: '权限管理',
          icon: 'privilege'
        }
      },
    ]
  },
  {
    path:'/carousel',
    component:Layout,
    children:[{
      path:'index',
      name:'Caeousel',
      component:()=>import('@/pages/carousel/index'),
      meta:{
        title:'轮播管理',
        icon:'carousel'
      }
    }]
  },
  // 404 page must be placed at the end !!!
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
